﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL.EntityRepository;
using POCOS;

namespace DAL.DBInteractions
{
    public class UnitOfWork : IUnitOfWork
    {
        private AuteurContext context;
        private readonly IDBFactory _databaseFactory;
        //private readonly IAuteurRepository _auteurRepository;

        //private readonly IArticleRepository _articleRepository;




        public UnitOfWork(IDBFactory databaseFactory)
        {
            this._databaseFactory = databaseFactory;

        }




        protected AuteurContext DataContext
        {
            get
            {
                return context ?? (context = _databaseFactory.Get());
            }


        }







     

        public EntityRepositoryBase<Themes> ThemesRepository
        {
            get { return new EntityRepositoryBase<Themes>(_databaseFactory); }
        }






        public void Commit()
        {
            DataContext.commit();
        }




       IUserProfileRepository IUnitOfWork.UserporfileRepository
        {
            get { return new UserProfileRepository(_databaseFactory); }
        }


        IAuteurRepository IUnitOfWork.AuteurRepository
        {
            get { return new AuteurRepository(_databaseFactory); }
        }

        IArticleRepository IUnitOfWork.ArticleRepository
        {
            get { return new ArticleRepository(_databaseFactory); }
        }
    }
}
